#include "BaseObject.h"

CBaseObject::CBaseObject()
{
	m_Rect = new hgeRect();
	m_IsBlock = false;
	m_CanDestory = false;
	m_Type = -1;
}

CBaseObject::CBaseObject(float l, float t, float w, float h)
{
	m_Rect = new hgeRect(l,t,l+w,t+h);
	m_Width = w;
	m_Height = h;
	m_IsBlock = false;
	m_CanDestory = false;
}

CBaseObject::~CBaseObject(void)
{
	if(m_Rect)
		delete m_Rect;
	m_Rect = NULL;
}

void CBaseObject::SetRect(float l, float t, float w, float h)
{
	m_Rect->x1 = l;
	m_Rect->y1 = t;
	m_Rect->x2 = l+w;
	m_Rect->y2 = t+h;
	m_Width = w;
	m_Height = h;
}

void CBaseObject::MoveRect(float x, float y)
{
	m_Rect->x1 = x;
	m_Rect->y1 = y;
	m_Rect->x2 = m_Rect->x1 + m_Width;
	m_Rect->y2 = m_Rect->y1 + m_Height;
}

void CBaseObject::GetPosition(float* x, float* y)
{
	if(x && y)
	{
		*x = m_Rect->x1;
		*y = m_Rect->y1;
	}
}

void CBaseObject::SetWidth(float w)
{
	m_Width = w;
	m_Rect->x2 = m_Rect->x1+w;
}

void CBaseObject::SetHeight(float h)
{
	m_Height = h;
	m_Rect->y2 = m_Rect->y1;
}